﻿<%@ Page Language="C#" MasterPageFile="~/Layouts/List.Master" AutoEventWireup="true" CodeBehind="OperationRuleList.aspx.cs" Inherits="Bingosoft.WebApp.Modules.SecurityConsole.Privilege.OperationRuleList" %>

<asp:Content ContentPlaceHolderID="head" ID="idFormTitle" runat="server">
    <!-- title -->    
</asp:Content>

<asp:Content ID="idContent" ContentPlaceHolderID="Content" runat="Server">     
    <div class="datalist">
	    <!-- 标题头 -->
	    <h2 style="height:30px;">
				    <%=Request["OperationName"]%>—规则列表
	    </h2>
	    <!-- 工具栏 -->
	    <div class="toolbar"  style="height:30px;">
            <asp:LinkButton runat="server"
                OnClientClick="return openEditor(this, 'Insert');" OnClick="SearchGrid">
                <span>
                    <img alt="" runat="server" id="img1" src="~/Images/icon_new.gif" style="border: 0px" />新建规则
                </span>
            </asp:LinkButton>
            <asp:LinkButton runat="server"
                OnClientClick="deletePermissionRules();" OnClick="DeletePermissionRules">
                <span>
                    <img alt="" runat="server" id="img2" src="~/Images/ico_del.gif" style="border: 0px" />删除规则
                </span>
            </asp:LinkButton>          
	    </div>
	    <div class="datagrid"  style="clear:left;">    
            <!--------------------------- List Area --------------------------->
            <web:SmartGridView ID="SmartGridView1" runat="server" AutoGenerateColumns="False"
                Width="100%" DataKeyNames="Id" DataSourceID="SmartDataSource1" PageSize="10">
                <Columns>
                    <asp:CheckBoxField DataField="Id"/>
                    <asp:BoundField DataField="Name" HeaderText="规则名称" SortExpression="Name" />
                    <asp:BoundField DataField="Priority" HeaderText="优先级" SortExpression="Priority" />
                    <asp:BoundField DataField="Rule" HeaderText="规则表达式" SortExpression="Rule" />
                    <asp:BoundField DataField="Behaviour" HeaderText="元素行为" SortExpression="Behaviour" />
                    
                    <asp:TemplateField HeaderText="操作">
                        <ItemStyle HorizontalAlign="Center" />
                        <HeaderStyle Wrap="False" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <table width="46px">
                                <tr>                                    
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ibtnEdit" runat="server" ToolTip="修改" _KeyId='<%#Eval("Id")%>'
                                            ImageUrl="~/images/com/dg_edit.gif" CausesValidation="False" OnClientClick="return openEditor(this, 'Edit');" OnClick="RefreshGrid">
                                        </asp:ImageButton>
                                    </td>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ibtnDelete" runat="server" ToolTip="删除" ImageUrl="~/images/com/dg_del.gif" _KeyId='<%#Eval("Id")%>'
                                            CausesValidation="False" OnClientClick="return confirm('您确认要删除吗?')" OnClick="DeletePermissionRule">
                                        </asp:ImageButton>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <CheckBoxSettings Enabled="True" Position="0"/> 
                <PagerSettings />
                <EditRowStyle HorizontalAlign="Center" />
            </web:SmartGridView>
    
            <web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="privilege.operation.rule.list"
            SelectCommandAutoPageWrap="true" DefaultSortExpression="Priority desc">       
            </web:SmartSqlDataSource>
        </div>
	</div>

    <script type="text/javascript">
        function openEditor(_this, action) {
            var url = "OperationRuleEdit.aspx";
            var operation = "<%=Request["Operation"] %>";
            var operationName = "<%=Request["OperationName"] %>";
            var elementId = "<%=Request["ElementId"] %>";
            var params = { FormViewMode: action };
            
            params.OperationName = operationName;
            params.elementId = elementId;
            if (_this.attributes["_KeyId"]) {
                params.title = "修改规则信息";
                params.Id = _this.attributes["_KeyId"].value;
                
            } else {
                params.title = "新增规则信息";
                params.Operation = operation;
            }

            var returnValue = showCenterModalDialog(buildUrl(url, params), 620, elementId == ""|| elementId == null?365:430, null);

            return returnValue == "true";
        }
        
        function deletePermissionRules() {
            var oSmartGridView1 = document.getElementById("<%=SmartGridView1.ClientID%>");
            var sValues = oSmartGridView1.control.getCheckedValues(true);

            if (sValues && sValues.length > 0) {
                return confirm('您确认要删除吗?');
            }

            alert("请您选择要删除的操作！");
            return false;
        }   
    </script>
</asp:Content>
